package com.me.client;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.me.ScreenMode;
import com.me.ScreenName;
import com.me.pojo.ComponentsItem;
import com.me.pojo.ScreenModeModel;
import org.junit.Test;
import com.me.utils.ScreenDataUtility;

import java.util.ArrayList;

/*
 * 测试java客户端发消息给unity服务端
 * */
public class BigScreenModeClient {
    /**
     * 运行大屏应急模式2-编排测试1
     */
    @Test
    public void runEmergencyMode2_test1() {
        //大屏模式数据开始
        ScreenModeModel mode = new ScreenModeModel();
        mode.setScreenName(ScreenName.ScreenN1.toString());
        mode.setScreenMode(ScreenMode.EmergencyMode2.toString());
        //模式下的所有组件
        ArrayList<ComponentsItem> allComps = new ArrayList<ComponentsItem>();

        //编排信息如下：
        //1.日期值班信息组件
        ComponentsItem item = new ComponentsItem("riQiZhiBanXinXi1", "riQiZhiBanXinXi", "(0,0)", "(2179.8,878)", new String[]{ScreenDataUtility.getRiQiZhiBanXinXiData()});
        allComps.add(item);
        //2.安全运营天数组件
        item = new ComponentsItem("anQuanYunYIngTianShu1", "anQuanYunYIngTianShu", "(2,0)", "(1070,878)", new String[]{ScreenDataUtility.getAnQuanYunYingTianShuData()});
        allComps.add(item);
        //3.车站报警次数排名
        item = new ComponentsItem("cheZhanBaoJingPaiMing1", "cheZhanBaoJingPaiMing", "(11,1)", "(1063,878)", new String[]{ScreenDataUtility.getCheZhanBaoJingPaiMingData()});
        allComps.add(item);
        //4.主变负荷
        item = new ComponentsItem("zhuSuoFuHe1", "zhuSuoFuHe", "(11,2)", "(1069,872.1)", new String[]{ScreenDataUtility.getZhuSuoFuHeData()});
        allComps.add(item);
        //5.专业报警矩阵
        item = new ComponentsItem("zhuanYeBaoJingJuZhen1", "zhuanYeBaoJingJuZhen", "(9,1)", "(2186.2,878)", new String[]{ScreenDataUtility.getZhuanYeBaoJingJuZhenData()});
        allComps.add(item);
        //6.能耗趋势图
        item = new ComponentsItem("nengHaoQuShiTu1", "nengHaoQuShiTu", "(9,2)", "(2186.2,878)", new String[]{ScreenDataUtility.getNengHaoQuShiTuData()});
        allComps.add(item);
        //7.列车行车指标
        item = new ComponentsItem("lieCheXingCheZhiBiao1", "lieCheXingCheZhiBiao", "(2,2)", "(1071.5,872.1)", new String[]{ScreenDataUtility.getLieCheXingCheZhiBiaoData()});
        allComps.add(item);
        //8.车站客流排名
        item = new ComponentsItem("15minCheZhanKeLiuPaiMing1", "15minCheZhanKeLiuPaiMing", "(2,1)", "(1070.5,878)", new String[]{ScreenDataUtility.getCheZhanKeLiuPaiMingData()});
        allComps.add(item);
        //9.15分钟客流趋势图
        item = new ComponentsItem("15minKeLiuQuShiTu1", "15minKeLiuQuShiTu", "(0,1)", "(2179.8,878)", new String[]{ScreenDataUtility.getKeLiuQuShiTuData()});
        allComps.add(item);
        //10.列车实时报点信息
        item = new ComponentsItem("lieCheShiShiBaoDianXinXi1", "lieCheShiShiBaoDianXinXi", "(0,2)", "(2179.8,878)", new String[]{ScreenDataUtility.getLieCheShiShiBaoDianXinXiData()});
        allComps.add(item);
        //11.可视化行车图
        item = new ComponentsItem("keShiHuaXingCheTu1", "keShiHuaXingCheTu", "(3,0)", "(6580.9,2660.9)", new String[]{""});
        allComps.add(item);
        //12.AFC客流明细图
        item = new ComponentsItem("AFCKeLiuMingXi1", "AFCKeLiuMingXi", "(9,0)", "(3268.5,875.76)", new String[]{""});
        allComps.add(item);
        mode.setComponents(allComps);
        doPost(mode);
    }

    /**
     * 运行大屏应急模式1-编排测试1
     */
    @Test
    public void runEmergencyMode1_test1() {
        //大屏模式数据开始
        ScreenModeModel mode = new ScreenModeModel();
        mode.setScreenName(ScreenName.ScreenN1.toString());
        mode.setScreenMode(ScreenMode.EmergencyMode1.toString());
        //模式下的所有组件
        ArrayList<ComponentsItem> allComps = new ArrayList<ComponentsItem>();

        //编排信息如下：
        //1.专业报警矩阵
        ComponentsItem item = new ComponentsItem("zhuanYeBaoJingJuZhen1", "zhuanYeBaoJingJuZhen", "(9,1)", "(2186.2,878)", new String[]{ScreenDataUtility.getZhuanYeBaoJingJuZhenData()});
        allComps.add(item);
        //2.车站报警次数排名
        item = new ComponentsItem("cheZhanBaoJingPaiMing1", "cheZhanBaoJingPaiMing", "(11,1)", "(1063,878)", new String[]{ScreenDataUtility.getCheZhanBaoJingPaiMingData()});
        allComps.add(item);
        //3.能耗趋势图
        item = new ComponentsItem("nengHaoQuShiTu1", "nengHaoQuShiTu", "(9,2)", "(2186.2,878)", new String[]{ScreenDataUtility.getNengHaoQuShiTuData()});
        allComps.add(item);
        //4.主变负荷
        item = new ComponentsItem("zhuSuoFuHe1", "zhuSuoFuHe", "(11,2)", "(1069,872.1)", new String[]{ScreenDataUtility.getZhuSuoFuHeData()});
        allComps.add(item);
        //5.15分钟客流趋势图
        item = new ComponentsItem("15minKeLiuQuShiTu1", "15minKeLiuQuShiTu", "(0,1)", "(2179.8,878)", new String[]{ScreenDataUtility.getKeLiuQuShiTuData()});
        allComps.add(item);
        //6.15分钟车站客流排名
        item = new ComponentsItem("15minCheZhanKeLiuPaiMing1", "15minCheZhanKeLiuPaiMing", "(2,1)", "(1070.5,878)", new String[]{ScreenDataUtility.getCheZhanKeLiuPaiMingData()});
        allComps.add(item);
        //7.列车实时报点信息
        item = new ComponentsItem("lieCheShiShiBaoDianXinXi1", "lieCheShiShiBaoDianXinXi", "(0,2)", "(2179.8,878)", new String[]{ScreenDataUtility.getLieCheShiShiBaoDianXinXiData()});
        allComps.add(item);
        //8.列车行车指标
        item = new ComponentsItem("lieCheXingCheZhiBiao1", "lieCheXingCheZhiBiao", "(2,2)", "(1071.5,872.1)", new String[]{ScreenDataUtility.getLieCheXingCheZhiBiaoData()});
        allComps.add(item);
        //9.CCTV1
        item = new ComponentsItem("CCTV1", "CCTV", "(0,0)", "(1082.5,872.4)", new String[]{""});
        allComps.add(item);
        //10.CCTV2
        item = new ComponentsItem("CCTV2", "CCTV", "(1,0)", "(1082.5,872.4)", new String[]{""});
        allComps.add(item);
        //11.CCTV3
        item = new ComponentsItem("CCTV3", "CCTV", "(2,0)", "(1082.5,872.4)", new String[]{""});
        allComps.add(item);
        //12.CCTV4
        item = new ComponentsItem("CCTV4", "CCTV", "(9,0)", "(1082.5,872.4)", new String[]{""});
        allComps.add(item);
        //13.CCTV5
        item = new ComponentsItem("CCTV5", "CCTV", "(10,0)", "(1082.5,872.4)", new String[]{""});
        allComps.add(item);
        //2.CCTV6
        item = new ComponentsItem("CCTV6", "CCTV", "(11,0)", "(1082.5,872.4)", new String[]{""});
        allComps.add(item);
        //14.可视化行车图2
        item = new ComponentsItem("keShiHuaXingCheTuTow1", "keShiHuaXingCheTuTow", "(3,0)", "(6580.9,2660.9)", new String[]{""});
        allComps.add(item);
        mode.setComponents(allComps);
        doPost(mode);
    }

    /**
     * 运行大屏参观模式-编排测试1
     */
    @Test
    public void runVisitMode_tes1() {
        //大屏模式数据开始
        ScreenModeModel mode = new ScreenModeModel();
        mode.setScreenName(ScreenName.ScreenN1.toString());
        mode.setScreenMode(ScreenMode.VisitMode.toString());
        //模式下的所有组件
        ArrayList<ComponentsItem> allComps = new ArrayList<ComponentsItem>();

        //编排信息如下：
        //1.月进站客流趋势
        ComponentsItem item = new ComponentsItem("yueJinZhanKeLiuQuShi1", "yueJinZhanKeLiuQuShi", "(9,0)", "(2171.1,878)", new String[]{ScreenDataUtility.getYueJinZhanKeLiuQuShiData()});
        allComps.add(item);
        //2.月行车趋势
        item = new ComponentsItem("yueXingCheQuShi1", "yueXingCheQuShi", "(9,1)", "(2171.1,878)", new String[]{ScreenDataUtility.getYueXingCheQuShiData()});
        allComps.add(item);
        //3.月能耗趋势
        item = new ComponentsItem("yueNengHaoQuShi1", "yueNengHaoQuShi", "(9,2)", "(2171.1,878)", new String[]{ScreenDataUtility.getYueNengHaoQuShiData()});
        allComps.add(item);
        //4.站年客流排名
        item = new ComponentsItem("zhanNianKeLiuPaiMing1", "zhanNianKeLiuPaiMing", "(11,0)", "(1070,878)", new String[]{ScreenDataUtility.getZhanNianKeLiuPaiMingData()});
        allComps.add(item);
        //5.行车指标
        item = new ComponentsItem("xingCheZhiBiao1", "xingCheZhiBiao", "(11,1)", "(1070,878)", new String[]{ScreenDataUtility.getXingCheZhiBiaoData()});
        allComps.add(item);
        //6.能耗类型占比
        item = new ComponentsItem("nengHaoLeiXingZhanBi1", "nengHaoLeiXingZhanBi", "(11,2)", "(1070,878)", new String[]{ScreenDataUtility.getNengHaoLeiXingZhanBiData()});
        allComps.add(item);
        //7.线路简介
        item = new ComponentsItem("xianLuJianJie1", "xianLuJianJie", "(0,0)", "(3254.9,867.3)", new String[]{""});
        allComps.add(item);
        //8.线路大事记简介
        item = new ComponentsItem("xianLuDaShiJi1", "xianLuDaShiJi", "(0,1)", "(3254.9,1761)", new String[]{""});
        allComps.add(item);
        //9.线路走向图
        item = new ComponentsItem("xianLuZouXiangTu1", "xianLuZouXiangTu", "(3,0)", "(6580.9,2660.9)", new String[]{""});
        allComps.add(item);
        mode.setComponents(allComps);
        doPost(mode);
    }

    /**
     * 运行大屏监察模式-编排测试1
     */
    @Test
    public void runSuperviseMode_test1() {
        //大屏模式数据开始
        ScreenModeModel mode = new ScreenModeModel();
        mode.setScreenName(ScreenName.ScreenN1.toString());
        mode.setScreenMode(ScreenMode.SuperviseMode.toString());
        //模式下的所有组件
        ArrayList<ComponentsItem> allComps = new ArrayList<ComponentsItem>();

        //编排信息如下：
        //1.月进站客流趋势
        ComponentsItem item = new ComponentsItem("yueJinZhanKeLiuQuShi1", "yueJinZhanKeLiuQuShi", "(9,0)", "(2171.1,878)", new String[]{ScreenDataUtility.getYueJinZhanKeLiuQuShiData()});
        //allComps.add(item);
        //2.月行车趋势
        item = new ComponentsItem("yueXingCheQuShi1", "yueXingCheQuShi", "(9,1)", "(2171.1,878)", new String[]{ScreenDataUtility.getYueXingCheQuShiData()});
        //allComps.add(item);
        //3.月能耗趋势
        item = new ComponentsItem("yueNengHaoQuShi1", "yueNengHaoQuShi", "(9,2)", "(2171.1,878)", new String[]{ScreenDataUtility.getYueNengHaoQuShiData()});
        //allComps.add(item);
        //4.站年客流排名
        item = new ComponentsItem("zhanNianKeLiuPaiMing1", "zhanNianKeLiuPaiMing", "(11,0)", "(1070,878)", new String[]{ScreenDataUtility.getZhanNianKeLiuPaiMingData()});
        //allComps.add(item);
        //5.行车指标
        item = new ComponentsItem("xingCheZhiBiao1", "xingCheZhiBiao", "(11,1)", "(1070,878)", new String[]{ScreenDataUtility.getXingCheZhiBiaoData()});
        //allComps.add(item);
        //6.能耗类型占比
        item = new ComponentsItem("nengHaoLeiXingZhanBi1", "nengHaoLeiXingZhanBi", "(11,2)", "(1070,878)", new String[]{ScreenDataUtility.getNengHaoLeiXingZhanBiData()});
        //allComps.add(item);
        //7.cctv1
        item = new ComponentsItem("CCTV1", "CCTV", "(6,1)", "(1070,878)", new String[]{""});
        allComps.add(item);
        //8.cctv2
        item = new ComponentsItem("CCTV2", "CCTV", "(7,1)", "(1070,878)", new String[]{""});
        allComps.add(item);
        //9.cctv3
        item = new ComponentsItem("CCTV3", "CCTV", "(6,2)", "(1070,878)", new String[]{""});
        allComps.add(item);
        //10.cctv4
        item = new ComponentsItem("CCTV4", "CCTV", "(7,2)", "(1070,878)", new String[]{""});
        allComps.add(item);
        //11.afc客流
        item = new ComponentsItem("AFCKeLiu1", "AFCKeLiu", "(6,0)", "(2178.1,860.7)", new String[]{""});
        allComps.add(item);
        //12.afc客流
        item = new ComponentsItem("AFCKeLiu1", "AFCKeLiu", "(6,0)", "(2178.1,860.7)", new String[]{""});
        allComps.add(item);
        //13.ats行车图
        item = new ComponentsItem("ATSXingCheTu1", "ATSXingCheTu", "(0,0)", "(6548.99,2656.1)", new String[]{""});
        //14.ats行车图
        item = new ComponentsItem("ATSXingCheTu1", "ATSXingCheTu", "(0,0)", "(6548.99,2656.1)", new String[]{""});
        allComps.add(item);
        //15.PSCADA
        item = new ComponentsItem("PSCADA1", "PSCADA", "(8,0)", "(4378.4,2656.1)", new String[]{""});
        allComps.add(item);
        mode.setComponents(allComps);
        doPost(mode);
    }

    private void doPost(ScreenModeModel mode) {
        ObjectMapper mapper = new ObjectMapper();
        String json = null;
        try {
            json = mapper.writeValueAsString(mode);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        String s = HttpClient.doPost("http://localhost:8085/ScreenMode", json);
        System.out.println("编排发送请求给大屏后收到的反馈信息如下：：：" + s);
    }
}